<template>
  <div style="position: absolute;top:-60px;z-index:999;width: 100%;" >
    <van-tabs v-model:active="active" @click="onClickTab" >
      <van-tab  title="上传错题"></van-tab>
      <van-tab title="查看题目"></van-tab>
      <van-tab title="上传汇总查看"></van-tab>
    </van-tabs>
  </div>
</template>

<script setup>
import { ref, nextTick, watch } from 'vue'
import { useRouter } from 'vue-router';
let router = useRouter();
const active = ref(0)
const onClickTab = async (e) => {
  console.log(e);
  let { innerText } = e.target;
  console.log(active.value);
  if (innerText == '上传错题') {
    await nextTick(); // 等待 Vue 的下一个渲染周期
    router.replace('/upload');
  }
  if (innerText == '查看题目') {
    await nextTick(); // 等待 Vue 的下一个渲染周期
    router.replace('/main');
  }
  if (innerText == '上传汇总查看') {
    await nextTick(); // 等待 Vue 的下一个渲染周期
    router.replace('/main/imgList/group');
  }
}
watch(() => active, async (newVal) => {
  console.log(active.value);
  active.value =Number(newVal);
  await nextTick(); // 等待 Vue 的下一个渲染周期
})
</script>

<style scoped lang="">
/* 样式 */
</style>
